﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace GiaoDien
{
    public partial class FORMDANGNHAP : Form
    {
        private string manhanvien;
        public FORMDANGNHAP()
        {
            InitializeComponent();
        }

        private void dangnhap()
        {
            NHANVIENBUS nvBUS = new NHANVIENBUS();
            manhanvien = txbmanhanvien.Text.Trim().ToUpper();
            MessageBox.Show(manhanvien);
            bool kq = nvBUS.kiemtradangnhap(manhanvien);
            if (kq == true)
            {
                MessageBox.Show("đăng nhập thành công");
                Form1.manhanvien = manhanvien;
                this.Close();
            }
            else
            {
                MessageBox.Show("đăng nhập thất bại");
                txbmanhanvien.ResetText();
                txbmanhanvien.Focus();
            }
        }

        private void txbmanhanvien_KeyUp(object sender, KeyEventArgs e)
        {
            if (txbmanhanvien.Text != "" && e.KeyCode == Keys.Enter)
                dangnhap();
        }

        private void btndangnhap_Click(object sender, EventArgs e)
        {
            dangnhap();
        }

        private void FORMDANGNHAP_Load(object sender, EventArgs e)
        {
            txbmanhanvien.Focus();
        }
    }
}
